<template>
  <div class="pagination">
    <el-pagination
      v-if="total"
      :background="background"
      :layout="layout"
      :total="total"
      :current-page="currentPage"
      :page-size="pageSize"
      :page-sizes="pageSizeOpt"
      @size-change="changePageSize"
      @current-change="changeCurrentPage"
    />
  </div>
</template>
<script>
export default {
  name: 'Page',
  props: {
    currentPage: {
      // 当前页码
      type: Number,
      required: true,
      default: 1
    },
    total: {
      // 数据总数
      type: Number,
      required: true,
      default: 0
    },
    pageSize: {
      // 每页条数
      type: Number,
      default: 10
    },
    layout: {
      type: String,
      default: 'total, prev, pager, next, sizes,jumper'
    },
    transfer: {
      //
      type: Boolean,
      default: true
    },
    pageSizeOpt: {
      // 每页条数切换的配置
      type: Array,
      default: function() {
        return [10, 20, 50, 100]
      }
    },
    showTip: {
      type: Boolean,
      default: true
    },
    background: {
      type: Boolean,
      default: true
    }
  },
  methods: {
    changeCurrentPage(currentPage) {
      this.$emit('change-current-page', currentPage, this.pageSize)
    },
    changePageSize(pageSize) {
      this.$emit('change-page-size', pageSize)
    }
  }
}
</script>
<style lang="scss" scoped>
.pagination {
    padding-top: 20px;
    text-align: center;
}
</style>
